<!doctype html>
<html>
<head>
  <meta charset='utf-8'>
  <title>Numeric cell type - Handsontable</title>

  <!--
  Loading Handsontable (full distribution that includes all dependencies)
  -->
  <link data-jsfiddle="common" rel="stylesheet" media="screen" href="../dist/handsontable.css">
  <link data-jsfiddle="common" rel="stylesheet" media="screen" href="../dist/pikaday/pikaday.css">
  <script data-jsfiddle="common" src="../dist/pikaday/pikaday.js"></script>
  <script data-jsfiddle="common" src="../dist/moment/moment.js"></script>
  <script data-jsfiddle="common" src="../dist/zeroclipboard/ZeroClipboard.js"></script>
  <script data-jsfiddle="common" src="../dist/handsontable.js"></script>
  <script data-jsfiddle="common" src="js/numeral.de-de.js"></script>

  <!--
  Loading demo dependencies. They are used here only to enhance the examples on this page
  -->
  <link data-jsfiddle="common" rel="stylesheet" media="screen" href="css/samples.css?20140331">
  <script src="js/samples.js"></script>
  <script src="js/highlight/highlight.pack.js"></script>
  <link rel="stylesheet" media="screen" href="js/highlight/styles/github.css">
  <link rel="stylesheet" href="css/font-awesome/css/font-awesome.min.css">

  <!--
  Facebook open graph. Don't copy this to your project :)
  -->
  <meta property="og:title" content="Numeric cell type">
  <meta property="og:description"
        content="Numeric cell type uses Numeral.js as the formatting library.">
  <meta property="og:url" content="http://handsontable.com/demo/numeric.html">
  <meta property="og:image" content="http://handsontable.com/demo/image/og-image.png">
  <meta property="og:image:type" content="image/png">
  <meta property="og:image:width" content="409">
  <meta property="og:image:height" content="164">
  <link rel="canonical" href="http://handsontable.com/demo/numeric.html">

  <!--
  Google Analytics for GitHub Page. Don't copy this to your project :)
  -->
  <script src="js/ga.js"></script>

  <script data-jsfiddle="common">
    function getCarData() {
      return [
        {car: "Mercedes A 160", year: 2006, price_usd: 6999.99, price_eur: 6999.99},
        {car: "Citroen C4 Coupe", year: 2008, price_usd: 8330, price_eur: 8330},
        {car: "Audi A4 Avant", year: 2011, price_usd: 33900, price_eur: 33900},
        {car: "Opel Astra", year: 2004, price_usd: 7000, price_eur: 7000},
        {car: "BMW 320i Coupe", year: 2011, price_usd: 30500, price_eur: 30500}
      ];
    }
  </script>
</head>

<body>


<div class="wrapper">
  <div class="wrapper-row">
    <div id="global-menu-clone">
      <h1><a href="../index.html">Handsontable</a></h1>

    </div>

    <div id="container">
      <div class="columnLayout">

        <div class="rowLayout">
      <div class="descLayout">
        <div class="pad" data-jsfiddle="example1">
          <a name="lazy"></a>

          <h2>Numeric cell type</h2>

          <p>By default, Handsontable treats all cell values as <code>string</code> type. This is because <code>&lt;textarea&gt;</code>
            returns a string as its value.</p>

          <p>In many cases you will prefer cell values to be treated as <code>number</code> type. This allows to format
            numbers nicely and sort them correctly.</p>

          <p>To trigger the Numeric cell type, use the option <code>type: 'numeric'</code> in <code>columns</code> array
            or
            <code>cells</code> function.</p>

          <p>Numeric cell type uses <a href="http://numeraljs.com/">Numeral.js</a> as the formatting library. Head over
            to
            their website to learn about the formatting syntax.</p>

          <p>To use number formatting style valid for your language (i18n), load language definition to Numeral.js. See
            "Languages" section in <a href="http://numeraljs.com/">Numeral.js docs</a> for more info.</p>

          <div id="example1"></div>

          <p>
            <button name="dump" data-dump="#example1" data-instance="hot" title="Prints current data source to Firebug/Chrome Dev Tools">
              Dump
              data to console
            </button>
          </p>
        </div>
      </div>

      <div class="codeLayout">
        <div class="pad">
          <div class="jsFiddle">
            <button class="jsFiddleLink" data-runfiddle="example1">Edit in jsFiddle</button>
          </div>

          <script data-jsfiddle="example1">
            var container = document.getElementById('example1'),
              hot;

            hot = new Handsontable(container, {
              data: getCarData(),
              startRows: 7,
              startCols: 4,
              colHeaders: ['Car', 'Year', 'Price ($)', 'Price (€)'],
              columnSorting: true,
              columns: [
                {
                  data: 'car'
                  // 1nd column is simple text, no special options here
                },
                {
                  data: 'year',
                  type: 'numeric'
                },
                {
                  data: 'price_usd',
                  type: 'numeric',
                  format: '$0,0.00',
                  language: 'en' // this is the default locale, set up for USD
                },
                {
                  data: 'price_eur',
                  type: 'numeric',
                  format: '0,0.00 $',
                  language: 'de' // i18n: use this for EUR (German)
                  // more locales available on numeraljs.com
                }
              ]
            });
          </script>
        </div>
      </div>
    </div>

        <div class="footer-text">
        </div>
      </div>

    </div>

  </div>
</div>

<div id="outside-links-wrapper"></div>

</body>
</html>
